﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GameDataLibrary;

namespace UtopianGame
{
    public class Infrastructure
    {
        public InfrastructureData xmlData;

        public Infrastructure(InfrastructureData newXMLData)
        {
            xmlData = newXMLData;
        }

        public void build()
        {
            if (Nation.moneyInTreasury >= xmlData.buildCost)
            {
                Nation.moneyInTreasury -= xmlData.buildCost;
                StatusEffect statusEffectToAdd = null;
                //find the status effect to add to the Nation.
                for (int i = 0; i < GlobalDataHolder.statusEffectArray.Length; i++)
                {
                    if (GlobalDataHolder.statusEffectArray[i].xmlData.name == xmlData.statusEffectName)
                    {
                        statusEffectToAdd = GlobalDataHolder.statusEffectArray[i];
                        statusEffectToAdd.regionNumber = GlobalDataHolder.currentlySelectedRegion;
                    }
                }
                Nation.statusEffectList.Add(statusEffectToAdd);

                //Then add the infrastructure's name to the appropriate region.
                Nation.regionList[GlobalDataHolder.currentlySelectedRegion].infrastructureList.Add(this.xmlData.name);
            }
        }
    }
}
